package com.open4cn.simulator.device;

import com.open4cn.simulator.core.device.IDeviceFactory;
import com.open4cn.simulator.core.exception.UnableToProcessException;
import com.open4cn.simulator.core.ext.DeviceEnum;
import com.open4cn.simulator.device.datacolor.DataColor1000Factory;
import com.open4cn.simulator.device.datacolor.DataColor600Factory;
import com.open4cn.simulator.device.huagao.HuaGao9000Factory;
import com.open4cn.simulator.device.xrite.Xrite7000Factory;
import com.open4cn.simulator.device.xrite.Xrite7800Factory;

/**
 * @author yinxiaopeng
 * @version 1.0.0
 * @company 致景科技
 * @department 飞梭BU/研发
 * @description
 * @Email yinxiaopeng@zj.tech
 * @date 2022-05-01 18:26
 */
public final class DeviceFactoryRoute {
    private DeviceFactoryRoute() {
    }

    public static IDeviceFactory route(String brand, String model) {
        DeviceEnum deviceEnum = which(brand, model);
        switch (deviceEnum) {
            case DATA_COLOR_600:
                return new DataColor600Factory();
            case DATA_COLOR_800:
            case DATA_COLOR_1000:
                return new DataColor1000Factory();
            case XRITE_7000:
                return new Xrite7000Factory();
            case XRITE_7800:
                return new Xrite7800Factory();
            case HUA_GAO_9000:
                return new HuaGao9000Factory();
            default:
                throw new UnableToProcessException(deviceEnum.getDesc() + ":设备模式不支持");
        }
    }

    private static DeviceEnum which(String brand, String model) {
        DeviceEnum deviceEnum = null;
        if (null != model) {
            deviceEnum = DeviceEnum.of(brand + "/" + model);
        } else {
            deviceEnum = DeviceEnum.of(brand);
        }
        return deviceEnum;
    }

}
